-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
selection_range: use merlin enclosing query instead of shape #1368
selection_range: use merlin enclosing query instead of shape #1368
Conversation
80f8871
to
b7c944f
Compare
Pull Request Test Coverage Report for Build 4581Details
💛 - Coveralls |
Does this work for documents that aren't well typed? |
I would expect it to behave as good (or as bad) as the current version. Looking at the Merlin implementation they do fairly similar things but shape returns too much information for our need. |
I just had this déjà-vu feeling. I openned a very similar PR 2 years ago... |
Yup. I just read it over and I still don't really understand how much this changes. I suppose you're confident that this is a strict improvement? A few tests would make that a lot more convincing. To recall my main desire for this feature: the criteria for what is a "selection" should be a purely syntactic one. It would make this command very useful for moving logical chunks of code around that don't need to be typed (comments, records field definitions, match statement clauses). |
It is true that the logic is quite different, but so far I was not able to witness any difference... I will try to write more interesting tests. The de-duplication is done explicitly in Merlin for the Still, it looks like the output of the I will write more test, but I would argue that it is a strict improvement: the code is simpler (on both sides, Merlin and OCaml-LSP), and the results do not contain duplicates anymore. I (still) agree with the fact that the Typedtree is probably not the best way to answer these queries, but that's out of scope for fix PR which aim is to remove duplicates. |
No argument against this being an improvement. You would know more than me. I would like to see some more tests to make sure we are understanding if there's a change of behavior or a regression. After hover and completion, this is my most used request in LSP. I imagine other users are also relying on this request heavily. We would all welcome improvements in this functionality. |
3abf2cd
to
4236933
Compare
@rgrinberg I added a few more tests and so far these changes only remove duplicate entries from the results. I also tried the feature a bit around the codebase and I am quite confident that there is no bad change in behavior. (I am not a regular user however, so I might miss some differences.) If you have some suggestion for some more precise tests cases I will be happy to add them, but right now I think this is ready to be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tests demonstrating the behavior with:
- modules containing a syntax error
- modules that are unable to type check
Would be appropriate I think
d5f5879
to
bcb5018
Compare
I added two more cases, one with a module with a definition that fails to type check (the return type is not the expected one), and one with an additional syntax error: the In both cases the new results appear to be a strict improvement (whose main aspect is the remove of duplicates). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top!
CHANGES: ## Features - Add custom [`ocamllsp/typeSearch`](/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md) request (ocaml/ocaml-lsp#1369) - Make MerlinJump code action configurable (ocaml/ocaml-lsp#1376) - Add custom [`ocamllsp/jump`](/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md) request (ocaml/ocaml-lsp#1374) ## Fixes - Fix fd leak in running external processes for preprocessing (ocaml/ocaml-lsp#1349) - Fix prefix parsing for completion of object methods (ocaml/ocaml-lsp#1363, fixes ocaml/ocaml-lsp#1358) - Remove some duplicates in the `selectionRange` answers (ocaml/ocaml-lsp#1368)
CHANGES: ## Features - Add custom [`ocamllsp/typeSearch`](/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md) request (ocaml/ocaml-lsp#1369) - Make MerlinJump code action configurable (ocaml/ocaml-lsp#1376) - Add custom [`ocamllsp/jump`](/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md) request (ocaml/ocaml-lsp#1374) ## Fixes - Fix fd leak in running external processes for preprocessing (ocaml/ocaml-lsp#1349) - Fix prefix parsing for completion of object methods (ocaml/ocaml-lsp#1363, fixes ocaml/ocaml-lsp#1358) - Remove some duplicates in the `selectionRange` answers (ocaml/ocaml-lsp#1368)
CHANGES: ## Features - Add custom [`ocamllsp/typeSearch`](/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md) request (ocaml/ocaml-lsp#1369) - Make MerlinJump code action configurable (ocaml/ocaml-lsp#1376) - Add custom [`ocamllsp/jump`](/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md) request (ocaml/ocaml-lsp#1374) ## Fixes - Fix fd leak in running external processes for preprocessing (ocaml/ocaml-lsp#1349) - Fix prefix parsing for completion of object methods (ocaml/ocaml-lsp#1363, fixes ocaml/ocaml-lsp#1358) - Remove some duplicates in the `selectionRange` answers (ocaml/ocaml-lsp#1368)
@awilliambauer @pitag-ha I looked at the server answer to the
selectionRange
query after our discussion earlier today, and I noticed that they were, in fact, duplicated ranges:With that patch these are removed:
Sadly vscode still feels the need to add extraneous steps, notably when there is some indentation:
Screen.Recording.2024-09-03.at.17.36.03.mov
That's quite unfortunate... but this PR at least improves the servers' answer and does remove a few no-op steps compared to the previous behaviour.